package cn.easyproject.easyee.sm.cmsmoudle.service.impl;

import java.util.List;
import java.io.Serializable;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import cn.easyproject.easyee.sm.cmsmoudle.criteria.BasicCriteria;
import cn.easyproject.easyee.sm.cmsmoudle.entity.Basic;
import cn.easyproject.easyee.sm.cmsmoudle.dao.BasicDAO;
import cn.easyproject.easyee.sm.cmsmoudle.service.BasicService;
import cn.easyproject.easyee.sm.base.service.BaseService;
import cn.easyproject.easyee.sm.base.pagination.PageBean;

/**
 * Basic Service, generated by EasyAuto
 * Must extends BaseService
 * 
 * @author easyproject.cn
 * @version 1.0
 *
 * 
 */
@Service("basicService")
public class BasicServiceImpl extends BaseService implements BasicService {

		
	@Resource
	BasicDAO basicDAO;

	@Override
	public void save(Basic basic) {
		basicDAO.save(basic);
	}

	@Override
	public void delete(Serializable id) {
		basicDAO.delete(id);
	}
	@Override
	public void delete(String[] values) {
		basicDAO.deleteByIds(values);
	}
	
	@Override
	public void update(Basic o) {
		basicDAO.update(o);
	}

	@Override
	public Basic get(Serializable id) {
		return basicDAO.get(id);
	}

	@Override
	@SuppressWarnings("rawtypes")
	public void findByPage(PageBean pageBean, BasicCriteria basicCriteria) {
		pageBean.setFrom(" web_basic ");
		pageBean.setSelect("*");
		pageBean.setEasyCriteria(basicCriteria);
		
		// pagination
		basicDAO.pagination(pageBean);
	}

	@Override
	public int findMaxRow() {
		return basicDAO.findMaxRow();
	}
	
	@Override
	public int findMaxPage(int rowPerPage) {
		return (basicDAO.findMaxRow()-1)/rowPerPage+1;
	}

	@Override
	@SuppressWarnings("unchecked")
	public List<Basic> findAll(){
		return basicDAO.findAll();
	}

}
